package com.jinxiangyang.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jinxiangyang.domain.OperLog;
import com.jinxiangyang.service.OperLogService;
import com.jinxiangyang.mapper.OperLogMapper;
import com.jinxiangyang.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author jinxiangyang
 * @description 针对表【oper_log(操作日志记录)】的数据库操作Service实现
 * @createDate 2023-08-16 20:26:39
 */
@Service
public class OperLogServiceImpl extends ServiceImpl<OperLogMapper, OperLog>
        implements OperLogService {


    @Autowired
    private OperLogMapper operLogMapper;


    @Override
    public IPage<OperLog> getOperLogPage(Long pageNumber, Integer pageSize, OperLog operLog) {
        IPage<OperLog> ipge = new Page<>(pageNumber, pageSize);
        LambdaQueryWrapper<OperLog> lambdaQueryWrapper = new LambdaQueryWrapper<OperLog>();
        lambdaQueryWrapper.like(StringUtils.isNotEmpty(operLog.getTitle()), OperLog::getTitle, operLog.getTitle());
        lambdaQueryWrapper.like(StringUtils.isNotEmpty(operLog.getOperLocation()),OperLog::getOperLocation,operLog.getOperLocation());
        lambdaQueryWrapper.eq(operLog!=null&&operLog.getStatus()!=null&&operLog.getStatus()!=-1,OperLog::getStatus,operLog.getStatus());
        lambdaQueryWrapper.orderByDesc(OperLog::getOperTime);
        return operLogMapper.selectPage(ipge, lambdaQueryWrapper);
    }



    @Override
    public Boolean cleanByOperLog(){
        return operLogMapper.clean();
    }
}




